/**
 * Created by Administrator on 2016/12/2 0002.
 */
app.controller("operation",["$scope",'$location',function($scope,$location){
    $("a").click(function(e){
        e.preventDefault();
    });
    $(".remove").click(function(){
        $(".deleteOperation").show();
    });
    $scope.deleteOperation = function(){
        $(".deleteOperation").hide();
    };
    $scope.cancelDeleteOperation = function(){
        $(".deleteOperation").hide();
    };
    $('input').iCheck({
        checkboxClass: 'icheckbox_minimal-green',
        radioClass: 'iradio_minimal-green',
        increaseArea: '20%' // optional
    });
    $("#operationDate").daterangepicker({
        timePicker:true,
        timePickerIncrement:5,
        timePicker24Hour:true,
        maxDate:new Date(),
        locale:{
            format:"YYYY/MM/DD HH:mm",
            applyLabel : '确定',
            cancelLabel : '取消',
            fromLabel: '从',
            toLabel: '到',
            weekLabel: 'W',
            customRangeLabel: 'Custom Range',
            daysOfWeek:["日","一","二","三","四","五","六"],
            monthNames: ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
            firstDay:1
        }
    });
}]);
app.controller("opreationTable",["$scope",function($scope){
    $('#operationTable').bootstrapTable({
        columns: [
            {
                checkbox: true
            },{
                field: 'operOrder',
                title: '显示顺序'
            },{
                field: 'operationCode',
                title: '操作编码',
                align:"left",
                halign:"center",
                width:210
            },{
                field: 'name',
                title: '操作名称',
                align:"left",
                halign:"center"
            }, {
                field: 'cssName',
                title: '样式名称',
                align:"left",
                halign:"center",
                width:210
            }, {
                field: 'bindFun',
                title: '绑定函数',
                align:"left",
                halign:"center"
            }, {
                field: 'url',
                title: 'URL',
                align:"left",
                halign:"center",
                width:210
            }, {
                field: 'remark',
                title: '备注',
                align:"left",
                halign:"center",
                width:120
            },{
                field:"isValid",
                title:"有效",
                width:50
            },{
                field:"isShow",
                title:"显示",
                width:50
            }
        ],
        data: [
            {
                operOrder: '1',
                operationCode: 'PERMISSION_USER_ADD',
                name:"新增",
                cssName:"glyphicon glyphicon-plus",
                bindFun:'userAdd',
                url:'../../permission/add',
                remark:'增加用户',
                isValid:"<input type='checkbox'/>",
                isShow:"<input type='checkbox'/>"
            },{
                operOrder: '2',
                operationCode: 'PERMISSION_USER_EDIT',
                name:"编辑",
                cssName:"glyphicon glyphicon-edit",
                bindFun:'userEdit',
                url:'../../permission/edit',
                remark:'修改用户信息',
                isValid:"<input type='checkbox'/>",
                isShow:"<input type='checkbox'/>"
            },{
                operOrder: '3',
                operationCode: 'PERMISSION_USER_DEl',
                name:"删除",
                bindFun:'userRemove',
                url:'../../permission/remove',
                remark:'删除用户',
                cssName:"glyphicon glyphicon-remove",
                isValid:"<input type='checkbox'/>",
                isShow:"<input type='checkbox'/>"
            }
        ],
        undefinedText : " ",
        height:711,
        pageSize:15,
        pageList :[10,15,20]
    });
    $("tbody tr td:first-child").each(function(){
        $(this).css("padding-top","13px")
    });
    $("tbody td").each(function(){
        if($(this).children().length==0){
            var content = $(this).html();
            $(this).addClass("one-table-edit").html('<input type="text">').find("input").val(content);
        }
    });
    //添加按钮功能
    $(".add").click(function(){
        $('#operationTable').bootstrapTable('append',appendData());
        $("tbody td").each(function(){
            if($(this).children().length==0){
                var content = $(this).html();
                $(this).addClass("one-table-edit").html('<input type="text">').find("input").val(content);
            }
        });
        $("tbody tr td:first-child").each(function(){
            $(this).css("padding-top","13px")
        });
        function appendData(){
            var append = [];
            append.push({
                operOrder: ' ',
                operationCode: ' ',
                name:" ",
                cssName:" ",
                bindFun:' ',
                url:' ',
                remark:' ',
                isValid:"<input type='checkbox'/>",
                isShow:"<input type='checkbox'/>"
            });
            return append;
        }
    });
    $(".fixed-table-container").css("border-bottom","1px solid #aaa4a4");
}]);